<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>while验证用户名和密码</title>
</head>

<body>
    <script>
        var username = prompt('请输入用户名');
        var password = prompt('请输入密码');
        while (username != "jty" || password != "123456") {
            alert("用户名或密码错误!");
            username = prompt('请输入用户名');
            password = prompt('请输入密码');
        }
        alert("登陆成功!");
    </script>
</body>

</html>